/*************************************************
 * 描述: 表格样式委托工厂
 *
 * File: styleditemdelegatefactory.h
 * Author: shizhixin@mozihealthcare.cn
 * Date: 2025-10-21
 * Update: 
 * ************************************************/
#ifndef COREXI_COMMON_PC_STYLEDITEMDELEGATEFACTORY_H
#define COREXI_COMMON_PC_STYLEDITEMDELEGATEFACTORY_H

#include <map>
#include <functional>

#include <controls/table/head.h>

class QObject;
class QAbstractItemDelegate;
using item_det = cxitable::ItemDelegateType;
using item_create_t = std::function<QAbstractItemDelegate*(const cxitable::GridColumnConfig&, QObject*)>;

class StyledItemDelegateFactory
{
public:
	/**
	 * 初始化，工厂注册相关委托
	 * @param parent
	 */
	static void init(QObject* parent = nullptr);

	/**
	 * 注册委托
	 * @param type
	 * @param func
	 */
	static void registerDelegate(item_det type, item_create_t func);

	/**
	 * 创建委托
	 * @param col
	 * @param parent
	 * @return
	 */
	static QAbstractItemDelegate* createDelegate(const cxitable::GridColumnConfig& col, QObject* parent = nullptr);

private:
	static std::map<item_det, item_create_t> m_items;
};


#endif //COREXI_COMMON_PC_STYLEDITEMDELEGATEFACTORY_H